package io.hepu.robotize.base;

import io.hepu.robotize.aop.Audit;
import io.hepu.robotize.http.HttpResponse;
import io.hepu.robotize.page.PageRequest;
import io.hepu.robotize.page.PageResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Collections;
import java.util.List;

public interface IBaseController<T, ID> {

    @Operation(summary = "通过ID查询实体", description = "返回实体对象")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "请求成功"),
            @ApiResponse(responseCode = "404", description = "对象不存在", content = @Content)
    })
    default HttpResponse<T> get(@Parameter(description = "实体ID，不能为空", required = true) ID id) throws Exception {
        return HttpResponse.success();
    }

    @Audit
    @Operation(summary = "创建对象实体", description = "返回对象实体")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "创建成功"),
            @ApiResponse(responseCode = "403", description = "禁止访问")
    })
    default HttpResponse<T> create(@Parameter(description = "实体对象", required = true) EntityRequest<T> request) throws Exception {
        return HttpResponse.success();
    }

    @Audit
    @Operation(summary = "更新对象实体", description = "返回更新后对象实体")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "更新成功"),
            @ApiResponse(responseCode = "403", description = "禁止访问"),
            @ApiResponse(responseCode = "404", description = "对象不存在", content = @Content)
    })
    default HttpResponse<T> edit(@Parameter(description = "实体对象", required = true) EntityRequest<T> request) throws Exception {
        return HttpResponse.success();
    }

    @Audit
    @Operation(summary = "删除对象实体", description = "返回被删除对象实体")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "删除成功"),
            @ApiResponse(responseCode = "403", description = "禁止访问"),
            @ApiResponse(responseCode = "404", description = "对象不存在", content = @Content)
    })
    default HttpResponse<T> delete(@Parameter(description = "实体对象", required = true) EntityRequest<T> request) throws Exception {
        return HttpResponse.success();
    }

    @Audit
    @Operation(summary = "通过ID删除对象实体", description = "返回被删除对象实体的ID数组")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "删除成功"),
            @ApiResponse(responseCode = "403", description = "禁止访问")
    })
    default HttpResponse<ID[]> delete(@Parameter(description = "实体ID数组", required = true) ID[] primaryKeys) throws Exception {
        return HttpResponse.success();
    }

    @Operation(summary = "分页查询对象实体", description = "返回对象实体列表与分页信息")
    @ApiResponses({
            @ApiResponse(responseCode = "200", description = "请求成功"),
            @ApiResponse(responseCode = "403", description = "禁止访问")
    })
    default HttpResponse<PageResponse<T>> paging(@Parameter(description = "查询请求") PageRequest pageRequest) throws Exception {
        return HttpResponse.success();
    }
}
